/**
*  \file sinc.h
*
*  \brief Saturated increment functions.
*
*  \author Michael J. Hohmann <michael.hohmann@linde-mh.de>
*
*
*/

#ifndef SINC_H_INCLUDED
#define SINC_H_INCLUDED

/*================================================[ public includes  ]================================================*/
#include "../cfg/prj.h"

/*================================================[ inline functions ]================================================*/

/**
*  Saturated increment U8
*
*  The function sinc_u8 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE U8 sinc_u8( U8 value )
{
   if( U8_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment UX8
*
*  The function sinc_ux8 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE UX8 sinc_ux8( UX8 value )
{
   if( UX8_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment S8
*
*  The function sinc_s8 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE S8 sinc_s8( S8 value )
{
   if( S8_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment SX8
*
*  The function sinc_sx8 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE SX8 sinc_sx8( SX8 value )
{
   if( SX8_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment U16
*
*  The function sinc_u16 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE U16 sinc_u16( U16 value )
{
   if( U16_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment UX16
*
*  The function sinc_ux16 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE UX16 sinc_ux16( UX16 value )
{
   if( UX16_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment S16
*
*  The function sinc_s16 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE S16 sinc_s16( S16 value )
{
   if( S16_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment SX16
*
*  The function sinc_sx16 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE SX16 sinc_sx16( SX16 value )
{
   if( SX16_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment U32
*
*  The function sinc_u32 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE U32 sinc_u32( U32 value )
{
   if( U32_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment UX32
*
*  The function sinc_ux32 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE UX32 sinc_ux32( UX32 value )
{
   if( UX32_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment S32
*
*  The function sinc_s32 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE S32 sinc_s32( S32 value )
{
   if( S32_MAX > value )
   {
      value++;
   }
   return value;
}

/**
*  Saturated increment SX32
*
*  The function sinc_sx32 increments the passed value as long as this does not overflow,
*  and returns it.
*
*   \param value Value to be incremented.
*
*   \return The incremented value.
*/
STATIC_INLINE SX32 sinc_sx32( SX32 value )
{
   if( SX32_MAX > value )
   {
      value++;
   }
   return value;
}

/*====================================================================================================================*/

#endif

/***********************************************************************************************************************
*                             Copyright 2011 Linde Material Handling. All rights reserved.                             *
***********************************************************************************************************************/
